<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<div>
    <div>sse测试</div>
    <div id="data"></div>
</div>
<script src="../js/jquery-3.7.1.min.js"></script>
<script src="../js/crypto-js.min.js"></script>
<script src="../js/common.js"></script>
<script src="/lay/t-secrypt-script.js"></script>
<script>
    var source = new EventSource('http://127.0.0.1:8084/sse/createConnect?clientId=ddz');
    source.onmessage = function (event) {
        text = document.getElementById('data').innerText;
        text += '\n' + event.data;
        document.getElementById('data').innerText = text;
    };
    <!-- 添加一个开启回调 -->
    source.onopen = function (event) {
        text = document.getElementById('data').innerText;
        text += '\n 开启: ';
        console.log(event);
        document.getElementById('data').innerText = text;
    };
</script>
</body>
</html>